/* hooks */
import { useLoading } from "@hooks/useLoading"
/* model */
import MsgModel from "@model/MsgModel"
import Page from '@model/Page.ts'
import { 
  CheckRepeatRobotSettingReleaseChannelModel,
  CreateChatRobotModel, 
  DeleteChatRobotModel, 
  DeleteGPTRobotAppServiceModel, 
  GetAddGPTRobotAppModel, 
  GetGPTRobotAppListModel, 
  GetRobotLogCountListModel, 
  RobotAppRangeInsertModel, 
  RobotAppWikiTypeInsertModel, 
  RobotAppWikiTypeQueryModel, 
  ToggleChatRobotModel, 
  UpdateChatRobotNameModel, 
  UpdateOpenDDAssistantModel, 
  UpdateRobotSettingModelNameModel, 
  UpdateRobotSettingReleaseChannelModel, 
  UpdateRobotSettingShareModel
} from "@model/param/in/AI"
/* api */
import { 
  addRobotApp, 
  checkRepeatRobotSettingReleaseChannel, 
  createRobot, 
  deleteRobot, 
  deleteRobotApp, 
  getRobotAppList, 
  getRobotAppServiceListWithSetting, 
  getRobotAppServiceListWithSettingShare, 
  getRobotList, 
  getRobotLogCountList, 
  getSystemRobot, 
  robotAppRangeInsert, 
  robotAppWikiTypeInsert, 
  robotAppWikiTypeQuery, 
  toggleRobot, 
  updateRobotName, 
  updateRobotSettingModelName, 
  updateRobotSettingOpenDDAssistant, 
  updateRobotSettingReleaseChannel, 
  updateRobotSettingShare
} from "@src/api/AIApi"
/* types */
import { AIChatRobotItemType } from "@src/component/business/BizChatPanel/chat/types"
import { DELETE_SUCCESS_MESSAGE } from "@src/model/const/Alert"
/* util */
import { message, confirm } from '@src/util/message'
import { isEmpty, isFalsy } from "@src/util/type"
import { transformRobotAppToComponentRobotItem, transformRobotServerItemToComponentItem } from "@gpt/utils"
import { getRootWindow } from "pub-bbx-utils"
/* vue */
import { computed, Ref, ref } from "vue"
/* types */
import { 
  AIChatRobotItemComponentType,
  SettingGPTRobotAppItem, 
  SettingGPTRobotLogCountItem, 
  SettingGPTRobotType, 
  SettingGPTServiceItem, 
  ShbGptRobotAppWikiType
} from "@src/modules/setting/gpt/types"
/* model */
import { DefaultRobotItem, SettingGPTServiceTypeEnum } from "@gpt/model"

/** 
 * @description GPT 机器人 列表
*/
function useBSHSettingGPTRobotList() {
  
  
  // 获取 GPT 机器人 列表
  const { 
    loading: fetchGptRobotListLoading,
    fetchGptRobotList,
    gptRobotList,
    gptRobotPage
  } = useFetchSettingGPTRobotList()
  
  // 删除 GPT 机器人
  const {
    loading: fetchDeleteGPTRobotLoading,
    isSuccess: isFetchDeleteGPTRobotSuccess,
    fetchDeleteGPTRobot
  } = useFetchSettingGPTRobotDelete()
  
  // 切换 GPT 机器人 状态
  const {
    loading: fetchToggleGPTRobotLoading,
    isSuccess: isFetchToggleGPTRobotSuccess,
    fetchToggleGPTRobot
  } = useFetchBSHSettingToggleGPTRobot()
  
  const {
    loading: fetchCreateGPTRobotLoading,
    isSuccess: isFetchCreateGPTRobotSuccess,
    fetchCreateGPTRobot,
    robotId
  } = useFetchSettingGPTRobotCreate()
  
  const {
    loading: fetchUpdateGPTRobotNameLoading,
    isSuccess: isFetchUpdateGPTRobotNameSuccess,
    fetchUpdateGPTRobotName
  } = useFetchSettingGPTRobotUpdateName()
  
  // 加载状态
  const loading = computed(() => {
    return (
      fetchGptRobotListLoading.value
      || fetchDeleteGPTRobotLoading.value
      || fetchToggleGPTRobotLoading.value
      || fetchCreateGPTRobotLoading.value
      || fetchUpdateGPTRobotNameLoading.value
    )
  })
  
  // 初始化
  const initialize = () => {
    fetchGptRobotList()
  }
  
  /** 
   * @description 删除机器人项
  */
  const onDeleteGPTRobotHandler = async (item: SettingGPTRobotType) => {
    
    const confirmed = await confirm.warning('删除后，自动解除与其他应用的绑定，确定删除？')
    if (isFalsy(confirmed)) {
      return
    }
    
    const params: DeleteChatRobotModel = {
      id: item.id
    }
    
    fetchDeleteGPTRobot(params).then(() => {
      
      if (isFetchDeleteGPTRobotSuccess.value) {
        fetchGptRobotList()
      }
      
    })
    
  }
  
  /** 
   * @description 修改机器人状态
  */
  const onToggleHandler = (item: ToggleChatRobotModel, enable: number) => {
    
    const params: ToggleChatRobotModel = {
      id: item.id,
      enable: enable
    }
    
    return (
      fetchToggleGPTRobot(params).then(() => {
        
        if (isFetchToggleGPTRobotSuccess.value) {
          fetchGptRobotList()
        }
        
        return isFetchToggleGPTRobotSuccess.value
        
      })
    )
    
  }
  
  const onCreateGPTRobotHandler = (params: CreateChatRobotModel) => {
    return (
      fetchCreateGPTRobot(params).then(() => {
        
        if (isFetchCreateGPTRobotSuccess.value) {
          fetchGptRobotList()
        }
        
        return {
          isSuccess: isFetchCreateGPTRobotSuccess.value,
          robotId: robotId.value,
          name: params.name
        }
        
      })
    )
  }
  
  const onUpdateGPTRobotNameHandler = (params: UpdateChatRobotNameModel) => {
    return (
      fetchUpdateGPTRobotName(params).then(() => {
        
        if (isFetchUpdateGPTRobotNameSuccess.value) {
          fetchGptRobotList()
        }
        
        return isFetchUpdateGPTRobotNameSuccess.value
        
      })
    )
  }
  
  return {
    loading,
    initialize,
    fetchGptRobotList,
    gptRobotList,
    gptRobotPage,
    onDeleteGPTRobotHandler,
    onToggleHandler,
    onCreateGPTRobotHandler,
    onUpdateGPTRobotNameHandler
  }
}

/**
 * @description 获取 小宝 GPT 机器人列表
 */
function useFetchSettingGPTRobotList() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const gptRobotList: Ref<AIChatRobotItemType[]> = ref([])
  const gptRobotPage: Ref<Page<AIChatRobotItemType[]>> = ref(new Page())
  
  const fetchGptRobotList = () => {
    
    setLoading()
    
    return (
      getRobotList().then(result => {
        
        if (MsgModel.isSuccess(result)) {
          
          const data = MsgModel.getData<AIChatRobotItemType[]>(result, [] as AIChatRobotItemType[])
          
          gptRobotList.value = data
          
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    fetchGptRobotList,
    gptRobotList,
    gptRobotPage
  }
}

/**
 * @description 切换 小宝 GPT 机器人 状态
 */
function useFetchBSHSettingToggleGPTRobot() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  const isSuccess: Ref<boolean> = ref(false)
  
  const fetchToggleGPTRobot = (params: ToggleChatRobotModel) => {
    
    setLoading()
    
    return (
      toggleRobot(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        
        if (isSuccess.value) {
          
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    isSuccess,
    fetchToggleGPTRobot
  }
}

/**
 * @description 删除 小宝 GPT 机器人
 */
function useFetchSettingGPTRobotDelete() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  const isSuccess: Ref<boolean> = ref(false)
  
  const fetchDeleteGPTRobot = (params: DeleteChatRobotModel) => {
    
    setLoading()
    
    return (
      deleteRobot(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        
        if (isSuccess.value) {
          message.success(DELETE_SUCCESS_MESSAGE)
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    isSuccess,
    fetchDeleteGPTRobot
  }
}

/**
 * @description 新建 小宝 GPT 机器人
 */
function useFetchSettingGPTRobotCreate() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  const isSuccess: Ref<boolean> = ref(false)
  
  const robotId: Ref<string> = ref('')
  
  const fetchCreateGPTRobot = (params: CreateChatRobotModel) => {
    
    setLoading()
    
    return (
      createRobot(params).then(result => {
        
        robotId.value = MsgModel.getData<string>(result, '')
        isSuccess.value = MsgModel.isSuccess(result)
        
        if (isSuccess.value) {
          message.success('新建成功')
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
      })
      .catch(err => {
        const errorMessage = MsgModel.getMessage(err?.response?.data) || MsgModel.getMessage(err)
        message.error(errorMessage)
      })
      .finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    robotId,
    isSuccess,
    fetchCreateGPTRobot
  }
}

/**
 * @description 更新 小宝 GPT 机器人
 */
function useFetchSettingGPTRobotUpdateName() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  const isSuccess: Ref<boolean> = ref(false)
  
  const fetchUpdateGPTRobotName = (params: UpdateChatRobotNameModel) => {
    
    setLoading()
    
    return (
      updateRobotName(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        
        if (isSuccess.value) {
          message.success('更新成功')
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    isSuccess,
    fetchUpdateGPTRobotName
  }
}

/**
 * @description 获取 小宝 GPT 机器人应用列表
 */
function useFetchSettingGPTRobotAppList() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const gptRobotAppList: Ref<SettingGPTServiceItem[]> = ref([])
  const chatRobotAppList: Ref<SettingGPTServiceItem[]> = ref([])
  
  const fetchGptRobotAppList = (params: GetGPTRobotAppListModel) => {
    
    setLoading()
    
    return (
      getRobotAppList(params).then(result => {
        
        if (MsgModel.isSuccess(result)) {
          
          const data = MsgModel.getData<SettingGPTRobotAppItem[]>(result, [] as SettingGPTRobotAppItem[])
          
          gptRobotAppList.value = transformRobotAppToComponentRobotItem(data)
          chatRobotAppList.value = gptRobotAppList.value.filter(item => {
            return item.type !== SettingGPTServiceTypeEnum.Summary
          })
          
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    fetchGptRobotAppList,
    gptRobotAppList,
    chatRobotAppList
  }
}

/**
 * @description 获取 小宝 GPT 机器人应用列表
 */
function useFetchSettingGPTRobotAppListWithSetting(isShare?: Ref<boolean>) {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const gptRobotAppListWithSetting: Ref<SettingGPTServiceItem[]> = ref([])
  const chatRobotAppList: Ref<SettingGPTServiceItem[]> = ref([])
  
  const fetchGptRobotAppListWithSetting = (params: GetGPTRobotAppListModel) => {
    
    setLoading()
    
    const fetchFunction = isShare?.value ? getRobotAppServiceListWithSettingShare : getRobotAppServiceListWithSetting
    
    return (
      fetchFunction(params).then(result => {
        
        if (MsgModel.isSuccess(result)) {
          
          const data = MsgModel.getData<SettingGPTRobotAppItem[]>(result, [] as SettingGPTRobotAppItem[])
          
          gptRobotAppListWithSetting.value = transformRobotAppToComponentRobotItem(data)
          chatRobotAppList.value = gptRobotAppListWithSetting.value.filter(item => {
            return item.type !== SettingGPTServiceTypeEnum.Summary
          })
          
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
        return result
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    chatRobotAppList,
    fetchGptRobotAppListWithSetting,
    gptRobotAppListWithSetting
  }
}

/**
 * @description 添加 小宝 GPT 机器人应用
 */
function useFetchSettingGPTRobotAppAdd() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const isSuccess: Ref<boolean> = ref(false)
  
  const fetchGptRobotAppAdd = (params: GetAddGPTRobotAppModel) => {
    
    setLoading()
    
    return (
      addRobotApp(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        
        if (isSuccess.value) {
          // 
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
        return isSuccess.value
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    fetchGptRobotAppAdd,
    isSuccess
  }
}

/**
 * @description 删除 小宝 GPT 机器人应用
 */
function useFetchSettingGPTRobotAppDelete() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const isSuccess: Ref<boolean> = ref(false)
  
  const fetchGptRobotAppDelete = (params: DeleteGPTRobotAppServiceModel) => {
    
    setLoading()
    
    return (
      deleteRobotApp(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        
        if (isSuccess.value) {
          // 
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
        return isSuccess.value
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    fetchGptRobotAppDelete,
    isSuccess,
  }
}

/**
 * @description 获取 小宝 GPT 机器人 日志统计 列表
 */
function useFetchSettingGPTRobotLogCount() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const isSuccess: Ref<boolean> = ref(false)

  const countList: Ref<SettingGPTRobotLogCountItem[]> = ref([])
  
  const fetchGptRobotLogCount = (params: GetRobotLogCountListModel) => {
    
    setLoading()
    
    return (
      getRobotLogCountList(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        
        if (isSuccess.value) {
          const data = MsgModel.getData<SettingGPTRobotLogCountItem[]>(result, [] as SettingGPTRobotLogCountItem[])
          countList.value = data
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
        return isSuccess.value
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    countList,
    fetchGptRobotLogCount,
    isSuccess
  }
}

function useInitXiaoBaoChat() {
  
  function initChat() {
    const rootWindow = getRootWindow(window)
    rootWindow?.initBizChatPanelChat()
  }
  
  return {
    initChat
  }
}

/**
 * @description 获取 小宝 GPT 机器人
 */
function useFetchSettingGPTSystemRobot() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  let gptSystemRobot: Ref<AIChatRobotItemComponentType> = ref(DefaultRobotItem) as Ref<AIChatRobotItemComponentType>
  
  const fetchGptSystemRobot = () => {
    
    setLoading()
    
    return (
      getSystemRobot().then(result => {
        
        if (MsgModel.isSuccess(result)) {
          
          const data = MsgModel.getData<AIChatRobotItemType>(result, {} as AIChatRobotItemType)
          
          gptSystemRobot.value = transformRobotServerItemToComponentItem(data)
          
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    fetchGptSystemRobot,
    gptSystemRobot
  }
}

/**
 * @description 更新 小宝 GPT 机器人 - 模型名称
 */
function useFetchSettingGPTRobotUpdateSettingModelName() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const isSuccess: Ref<boolean> = ref(false)
  
  const fetchUpdateGptRobotSettingModelName = (params: UpdateRobotSettingModelNameModel) => {
    
    setLoading()
    
    return (
      updateRobotSettingModelName(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        
        if (isSuccess.value) {
          // 
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    isSuccess,
    fetchUpdateGptRobotSettingModelName
  }
}

/**
 * @description 更新 小宝 GPT 机器人 - 分享状态
 */
function useFetchSettingGPTRobotUpdateSettingShare() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const isSuccess: Ref<boolean> = ref(false)
  
  const fetchUpdateGptRobotSettingShare = (params: UpdateRobotSettingShareModel) => {
    
    setLoading()
    
    return (
      updateRobotSettingShare(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        
        if (isSuccess.value) {
          // 
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    isSuccess,
    fetchUpdateGptRobotSettingShare
  }
}

/**
 * @description 更新 小宝 GPT 机器人 - 权限范围
 */
function useFetchSettingGPTRobotAppRangeInsert() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const isSuccess: Ref<boolean> = ref(false)
  
  const fetchRobotAppRangeInsert = (params: RobotAppRangeInsertModel) => {
    
    setLoading()
    
    return (
      robotAppRangeInsert(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        
        if (isSuccess.value) {
          // 
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
        return isSuccess.value
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    isSuccess,
    fetchRobotAppRangeInsert
  }
}

/**
 * @description 更新 小宝 GPT 机器人 - 知识库类型
 */
function useFetchSettingGPTRobotAppWikiTypeInsert() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const isSuccess: Ref<boolean> = ref(false)
  
  const fetchRobotAppWikiTypeInsert = (params: RobotAppWikiTypeInsertModel) => {
    
    setLoading()
    
    return (
      robotAppWikiTypeInsert(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        
        if (isSuccess.value) {
          // 
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
        return isSuccess.value
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    isSuccess,
    fetchRobotAppWikiTypeInsert
  }
}

/**
 * @description 更新 小宝 GPT 机器人 - 知识库查询
 */
function useFetchSettingGPTRobotAppWikiTypeQuery() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const isSuccess: Ref<boolean> = ref(false)
  const wikiTypeList: Ref<ShbGptRobotAppWikiType[]> = ref([])
  
  const fetchRobotAppWikiTypeQuery = (params: RobotAppWikiTypeQueryModel) => {
    
    setLoading()
    
    return (
      robotAppWikiTypeQuery(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        
        if (isSuccess.value) {
          const data = MsgModel.getData<ShbGptRobotAppWikiType[]>(result, [] as ShbGptRobotAppWikiType[])
          wikiTypeList.value = data
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
        return isSuccess.value
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    isSuccess,
    wikiTypeList,
    fetchRobotAppWikiTypeQuery
  }
}

/**
 * @description 更新 小宝 GPT 机器人 - 发布渠道
 */
function useFetchSettingGPTRobotUpdateSettingReleaseChannel() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const isSuccess: Ref<boolean> = ref(false)
  
  const fetchUpdateGptRobotSettingReleaseChannel = (params: UpdateRobotSettingReleaseChannelModel) => {
    
    setLoading()
    
    return (
      updateRobotSettingReleaseChannel(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        
        if (isSuccess.value) {
          // 
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    isSuccess,
    fetchUpdateGptRobotSettingReleaseChannel
  }
}

/**
 * @description 检查 小宝 GPT 机器人 - 发布渠道是否重复
 */
function useFetchSettingGPTRobotCheckRepeatSettingReleaseChannel() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const isRepeat: Ref<boolean> = ref(false)
  const isSuccess: Ref<boolean> = ref(false)
  
  const fetchCheckRepeatSettingReleaseChannel = (params: CheckRepeatRobotSettingReleaseChannelModel) => {
    
    setLoading()
    
    return (
      checkRepeatRobotSettingReleaseChannel(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        isRepeat.value = MsgModel.getData<boolean>(result, false)
        
        if (isSuccess.value) {
          // 
        } else {
          message.error(MsgModel.getMessage(result))
        }
        
        return isRepeat.value
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    isSuccess,
    isRepeat,
    fetchCheckRepeatSettingReleaseChannel
  }
}

/**
 * @description 更新 小宝 GPT 机器人 - 是否开启钉钉AI助理
 */
function useFetchSettingGPTRobotUpdateOpenDDAssistant() {
  
  const { loading, setLoading, clearLoading } = useLoading()
  
  const isSuccess: Ref<boolean> = ref(false)
  
  const fetchUpdateOpenDDAssistant = (params: UpdateOpenDDAssistantModel) => {
    
    setLoading()
    
    return (
      updateRobotSettingOpenDDAssistant(params).then(result => {
        
        isSuccess.value = MsgModel.isSuccess(result)
        
        return result
        
      }).finally(() => {
        clearLoading()
      })
    )
  }
  
  return {
    loading,
    isSuccess,
    fetchUpdateOpenDDAssistant
  }
}

export {
  useFetchSettingGPTRobotList,
  useBSHSettingGPTRobotList,
  useFetchSettingGPTRobotAppList,
  useFetchSettingGPTRobotAppAdd,
  useFetchSettingGPTRobotAppDelete,
  useFetchSettingGPTRobotLogCount,
  useInitXiaoBaoChat,
  useFetchSettingGPTRobotAppListWithSetting,
  useFetchSettingGPTSystemRobot,
  useFetchSettingGPTRobotUpdateSettingModelName,
  useFetchSettingGPTRobotUpdateSettingShare,
  useFetchSettingGPTRobotAppRangeInsert,
  useFetchSettingGPTRobotAppWikiTypeInsert,
  useFetchSettingGPTRobotAppWikiTypeQuery,
  useFetchSettingGPTRobotUpdateSettingReleaseChannel,
  useFetchSettingGPTRobotCheckRepeatSettingReleaseChannel,
  useFetchSettingGPTRobotUpdateOpenDDAssistant
}